package com.scau.XFourPOS.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * 类名称：ProductCategory 类描述：产品类别的model表 创建人：庄祥鹏
 * */
@Entity
@Table(name = "product_category")
public class ProductCategory {
	/**
	 * 构造函数
	 */
	public ProductCategory(String productCategory) {
		this.productCategory = productCategory;
	}

	public ProductCategory() {

	}
	/**
	 * 产品类别id
	 */
	@Id
	@Column(name = "product_category_id", unique = true, nullable = false)
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int productCategoryId;

	/**
	 * 产品所属的类别，如衣服属于衣服类别
	 */
	@Column(name = "product_category", unique = true, nullable = false, length = 50)
	private String productCategory;

	/**
	 * 【一个类别】对应【多款产品】 
	 *1-m,多的一方为关系维护端，关系维护端负责外键记录的更新，关系被维护端没有权利更新外键记录
	 *出现mapby为被维护端|||默认为延迟加载
	 */
	@Transient
	@OneToMany(cascade = { CascadeType.REFRESH, CascadeType.PERSIST,
			CascadeType.REMOVE, CascadeType.MERGE }, targetEntity = Product.class, mappedBy = "productCategory")
	private Set<Product> product = new HashSet<Product>();

	public int getProductCategoryId() {
		return productCategoryId;
	}

	public void setProductCategoryId(int productCategoryId) {
		this.productCategoryId = productCategoryId;
	}

	public String getProductCategory() {
		return productCategory;
	}

	public void setProductCategory(String productCategory) {
		this.productCategory = productCategory;
	}

	public Set<Product> getProduct() {
		return product;
	}

	public void setProduct(Set<Product> product) {
		this.product = product;
	}

}
